<div class="page">
	<style>
	#advSwiper{
		height:180px;
	}
	#advSwiper img{
		width:100%;
	}
	</style>
	<div class="bar bar-header bar-clear">
		<a class="button button-clear" href="{php echo $this->createMobileUrl('index')}">
			<i class="icon ion-ios-arrow-back active"></i>
			<span class="active">听单</span>
		</a>
		<h2 class="title"></h2>
		<a class="button button-clear" href="{php echo $this->createMobileUrl('runner')}">
			<span class="active">跑腿中心</span>
		</a>
	</div>
	<div class="swiper-container" id="advSwiper">
		<div class="swiper-wrapper">
			{loop $advs $adv}
				<a href="{php echo $adv['link']}" class="swiper-slide">
					<img src="{php echo tomedia($adv['image'])}" />
				</a>
			{/loop}
		</div>
	</div>
	<div class="hd tasks">
		<div class="list">
			{loop $orders $order}
			<a class="item item-avatar" data-pjax href="{php echo $this->createMobileUrl('detail',array('id'=>$order['id']))}">
				<img src="{$order['user']['avatar']}" alt="{$order['user']['nickname']}" />
				<h2 class="title">{$order['user']['nickname']}</h2>
				<p style="white-space: normal;color:gray;">{$order['text']}</p>
				<span>{$order['create_time']}</span>
				<p>城市：{$order['city']}</p>
				{if $order['status'] == 1}
				<i class="badge badge-assertive" style="margin-top: -10px;">等待中</i>
				{else}
				<i class="badge badge-stable" style="margin-top: -10px;">已被抢</i>
				{/if}
			</a>
			{/loop}
		</div>
	</div>
</div>
<script>
require(['jquery','core','swiper'],function($,core){
	$('#footer').show();
	core.post('check',{act:'runner'},function(data){
		if(data.status == 0){
			addTime();
		}else if(data.status == 1){
			//余额不足
			core.ok(data.message,function(){
				$.pjax({
					url:""+data.url,
					container:'#pjax-container'
				});
			},function(){
				$.pjax({
					url:""+data.url,
					container:'#pjax-container'
				});
			});
		}else{
			core.ok(data.message,function(){
				$.pjax({
					url:""+data.url,
					container:'#pjax-container'
				});
			},function(){
				$.pjax({
					url:""+data.url,
					container:'#pjax-container'
				});
			});
		}
	});
	
	var mySwiper = new Swiper('#advSwiper', {
		autoplay: 3000,
		loop : true,
		effect : 'fade',
	});
	var page1 = 2;
	var status1 = 1;
	var params = {page:2,act:'more'}
	window.onscroll = function(){
		params.page = page1;
		loadMore(params);
	}
	
	function loadMore(params,call){
		if ($(document).scrollTop() + $(window).height() > $(document).height() - 30) {
			if(status1 == 0){
				return ;
			}
			status1 = 0;
			core.post('tasks',params,function(data){
				if(data.status == 1){
					$('.tasks .list').append(data.data);
					status1 = 0;
				}
			});
		}
	}
});
</script>
{template 'default/common/share'}